<template>
  <div>
    <input type="text" v-model="inputValue" placeholder="请输入...">
    <button @click="handleSubmit">提交</button>
    <ul>
      <todo_item v-for="(item,index) of list"
      :key="index"
      :content="item"
      :index="index"
      @delete="handleDelete"
      ></todo_item>
    </ul>
  </div>
</template>

<script>
import TodoList from "./components/todolist";

export default {
  data() {
    return {
      inputValue: "",
      list: []
    };
  },
  components: {
    'todo_item': TodoList
  },
  methods: {
    handleSubmit() {
      this.list.push(this.inputValue);
      this.inputValue = "";
    },
    handleDelete(index) {
      this.list.splice(index, 1);
    }
  }
};
</script>

<style>
</style>
